package org.com.thang.dept;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.com.system.util.mate.Link;
import org.com.system.util.mate.SQLMate;
import org.com.system.util.model.Model;
import org.com.thang.user.TUser;

import org.hibernate.annotations.GenericGenerator;

@Entity
@Inheritance(strategy=InheritanceType.JOINED)
@Table(name="t_dept_info",catalog="thang")
public class Dept extends Model{

	private String id;
	@SQLMate(link=Link.LIKE)
	private String deptName;
	private String deptCode;
	private String deptPerson;
	private String opt;
	
	private Set<TUser> users=new HashSet<TUser>(0);
	
	public Dept(){}
	
	
	public Dept(String deptName, String deptCode, String deptPerson,String opt) {
		this.deptName = deptName;
		this.deptCode = deptCode;
		this.deptPerson = deptPerson;
		this.opt = opt;
	}

	@Id
	@GenericGenerator(name="gener",strategy="uuid2")
	@GeneratedValue(generator="gener")
	@Column(name="id",unique=true,nullable=true)
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	@Column(name="dept_name",length=45)
	public String getDeptName() {
		return deptName;
	}
	public void setDeptName(String deptName) {
		this.deptName = deptName;
	}
	@Column(name="dept_code",length=45)
	public String getDeptCode() {
		return deptCode;
	}
	public void setDeptCode(String deptCode) {
		this.deptCode = deptCode;
	}
	@Column(name="dept_person",length=45)
	public String getDeptPerson() {
		return deptPerson;
	}
	public void setDeptPerson(String deptPerson) {
		this.deptPerson = deptPerson;
	}
	@Column(name="opt",length=245)
	public String getOpt() {
		return opt;
	}
	public void setOpt(String opt) {
		this.opt = opt;
	}
	@OneToMany(cascade={CascadeType.DETACH,CascadeType.MERGE,CascadeType.PERSIST},fetch=FetchType.LAZY,mappedBy="dept")
	public Set<TUser> getUsers() {
		return users;
	}
	public void setUsers(Set<TUser> users) {
		this.users = users;
	}
	
	
}
